from flask_shop.main import db
# https://github.com/pallets-eco/flask-sqlalchemy
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship
from sqlalchemy import Integer, String, ForeignKey, DateTime, Boolean, ARRAY, JSON
from datetime import datetime
from ..classes import *

# class ResourceStore(db.Model):
#     """
#     通用资源存储
#     """
#     __tablename__ = 't_resource_store'
#     id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True, comment='主键')
#     file_type: Mapped[int] = mapped_column(Integer, comment='文件类型 1: 视频  2：图片  3：音频')
#     created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, comment='创建时间')
#     url: Mapped[str] = mapped_column(String(128), default='', unique=True, comment='资源链接')


# class VideoResourceStore(db.Model):
#     """
#     视频资源储存
#     """
#     __tablename__ = 't_video_resource_store'
#     id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True, comment='主键')
#     source_from: Mapped[int] = mapped_column(Integer, comment='资源从哪里获取的 详细看枚举 PlatformType')
#     origin_user_id: Mapped[str] = mapped_column(String(32), comment='原来资源的用户id, 如果是自己合成的，则为null')
#     origin_create_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, comment='原视频创建时间')
#     origin_json: Mapped[dict] = mapped_column(JSON, default=None, comment='爬取出来的json数据，做备用')
#     created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, comment='创建时间')
#     like_number: Mapped[int] = mapped_column(Integer, default=0, comment='点赞数量')
#     comment_number: Mapped[int] = mapped_column(Integer, default=0, comment='评论数量')
#     video_id: Mapped[int] = mapped_column(Integer, ForeignKey('t_resource_store.id'), default=0, comment='视频的资源id')
#     used: Mapped[bool] = mapped_column(Boolean, default=False, comment='资源是否被使用过了')
#
#
#     #######################以下合成的视频资源才有值
#     video_from_id: Mapped[int] = mapped_column(Integer, ForeignKey('t_resource_store.id'), default=0, comment='从哪个视频中提取了视频')
#     audio_from_id: Mapped[int] = mapped_column(Integer, ForeignKey('t_resource_store.id'), default=0, comment='从哪个视频中获取了音频')
#     photo_id: Mapped[int] = mapped_column(Integer, ForeignKey('t_resource_store.id'), default=0, comment='主图资源')
#
#     video = relationship('ResourceStore', foreign_keys='video_id')
#     video_from = relationship('ResourceStore', foreign_keys='video_from_id')
#     audio_from = relationship('ResourceStore', foreign_keys='audio_from_id')
#     photo = relationship('ResourceStore', foreign_keys='photo_id')
